// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package com.geniusai.aip.auth.service.impl;

/**
 * cpu个数的转换
 * 
 * @author hml14563
 * @date 2021/5/6
 */
public enum CpuNumEnum {
    /**
     * million to core
     */
    M("m", 0.001),
    /**
     * nano to core
     */
    N("n", 0.000000001);

    private String format;
    private double value;

    CpuNumEnum(String format, double value) {
        this.format = format;
        this.value = value;
    }

    public static double getFormat(String format) {
        CpuNumEnum[] cpuEnums = CpuNumEnum.values();
        for (CpuNumEnum cpu : cpuEnums) {
            if (cpu.format().equals(format)) {
                return cpu.value();
            }
        }
        return 1;
    }

    public String format() {
        return format;
    }

    public double value() {
        return value;
    }

}
